package week9;

import java.io.IOException;
import javax.microedition.rms.InvalidRecordIDException;
import javax.microedition.rms.RecordStore;
import javax.microedition.rms.RecordStoreException;
import javax.microedition.rms.RecordStoreNotOpenException;

public class RMSAccount {
	private String fileName = "phoneAccount";

	public Account getAccount(int paramInt) {
		Account localAccount = null;
		try {
			RecordStore localRecordStore = null;
			localRecordStore = RecordStore.openRecordStore(this.fileName, true);
			localAccount = Account.deserialize(localRecordStore.getRecord(paramInt));
			localRecordStore.closeRecordStore();
		} catch (RecordStoreNotOpenException localRecordStoreNotOpenException) {
			localAccount = null;
		} catch (InvalidRecordIDException localInvalidRecordIDException) {
			localAccount = null;
		} catch (IOException localIOException) {
			localAccount = null;
		} catch (RecordStoreException localRecordStoreException) {
			localAccount = null;
		}
		return localAccount;
	}

	public boolean delAccount(int paramInt) {
		RecordStore localRecordStore;
		try {
			localRecordStore = null;
			localRecordStore = RecordStore.openRecordStore(this.fileName, true);
			localRecordStore.deleteRecord(paramInt);
			localRecordStore.closeRecordStore();
			return true;
		} catch (RecordStoreNotOpenException localRecordStoreNotOpenException) {
		} catch (InvalidRecordIDException localInvalidRecordIDException) {
		} catch (RecordStoreException localRecordStoreException) {
		}
		return false;
	}

	public boolean modiAccount(int paramInt, Account paramAccount) {
		byte[] arrayOfByte;
		try {
			return false;
		} catch (Exception localRecordStoreException) {
			try {
				try {
					arrayOfByte = paramAccount.serialize();
				} catch (IOException localIOException) {
					return false;
				}
				RecordStore localRecordStore = null;
				localRecordStore = RecordStore.openRecordStore(this.fileName, true);
				localRecordStore.setRecord(paramInt, arrayOfByte, 0, arrayOfByte.length);
				localRecordStore.closeRecordStore();
				return true;
			} catch (Exception e) {
			}
		}
		return false;
	}

	public int addAccount(Account localObject) {
		// TODO Auto-generated method stub
		return 0;
	}
}